Imports System.ComponentModel
Imports System.Data.OleDb

Partial Class DataDAL

    Public Function GetAll() As List(Of DataModel)
        Dim OleDb As New OleDbHelper()
        Dim table As New DataTable()
        Dim a As New List(Of DataModel)
        table = OleDb.ExecSelectNo("select * from 项目明细 order by 上边距", CommandType.Text)
        If Not IsNothing(table) Then
            For Each dr In table.Rows
                Dim m As New DataModel
                m.上边距 = dr("上边距")
                m.项目名称 = dr("项目名称")
                m.字体大小 = dr("字体大小")
                m.字体名称 = dr("字体名称")
                m.左边距 = dr("左边距")
                m.项目内容 = GetNull(dr("项目内容"))
                a.Add(m)
            Next
            Return a
        Else
            Return Nothing
        End If
    End Function
    Public Function GetAllLine() As List(Of LineModel)
        Dim OleDb As New OleDbHelper()
        Dim table As New DataTable()
        Dim a As New List(Of LineModel)
        table = OleDb.ExecSelectNo("select * from 画表", CommandType.Text)
        If Not IsNothing(table) Then
            For Each dr In table.Rows
                Dim m As New LineModel
                m.x起点 = dr("x起点")
                m.x终点 = dr("x终点")
                m.y终点 = dr("y终点")
                m.y起点 = dr("y起点")
                a.Add(m)
            Next
            Return a
        Else
            Return Nothing
        End If
    End Function
    Public Function GetNull(ByVal value As Object) As Object '取空值处理
        If IsDBNull(value) Then
            Return Nothing
        Else
            Return value
        End If
    End Function
    Public Function PutNull(ByVal value As Object) As Object '赋空值处理
        If IsNothing(value) Then
            Return DBNull.Value
        Else
            Return value
        End If
    End Function
End Class
